$(function (){
    //加载默认隐藏展示页
    $(".show").hide()
    //单击后获取输入内容
    $(".btn").bind("click",function (){
        var text = $(".text").val();
        console.log(text)
        $.ajax({
            type: "post",
            url: "/nlp?action=dialogue",
            data: {
                text: text,
            },
            dataType: "json",
            success: function (data){

                // console.log("成功")
                // console.log(data)

                $.each(data.items,function(index,obj){

                if(obj.label == "pessimistic"){
                    $("#pessimistic").html(obj.prob).css("color","red")
                }
                if(obj.label == "neutral"){
                    $("#neutral").html(obj.prob).css("color","orange")
                }
                if(obj.label == "optimistic"){
                    $("#optimistic").html(obj.prob).css("color","green")
                }
                    console.log("成功")
                })
            },
            err : function (data){
                console.log("失败")
            }
        })
        //单击后展示隐藏页面
        $(".show").show()
    })

})



